﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrainingWorkshop.MVPWebsite.Authority.Interface.Services;
using DataContracts;

namespace TrainingWorkshop.MVPWebsite.Authority.Services
{
    public class AuthorityService : IAuthorityService
    {
        ServiceAgent.ServiceAgent proxy = new ServiceAgent.ServiceAgent();

        /// <summary>
        /// Save a New Authority
        /// </summary>
        /// <param name="authorityDTO"></param>
        /// <returns></returns>
        public bool AddNewAuthority(AuthorityDTO authorityDTO)
        {
            return proxy.ServiceClient.AddNewAuthority(authorityDTO);
        }

        /// <summary>
        /// Delete Authority
        /// </summary>
        /// <param name="authorityId"></param>
        /// <returns></returns>
        public bool DeleteAuthority(int authorityId)
        {
            return proxy.ServiceClient.DeleteAuthority(authorityId);
        }

        /// <summary>
        /// Update Authority
        /// </summary>
        /// <param name="authorityDTO"></param>
        /// <returns></returns>
        public bool UpdateAuthority(AuthorityDTO authorityDTO)
        {
            return proxy.ServiceClient.UpdateAuthority(authorityDTO);
        }

        /// <summary>
        /// Get Authority by Current AuthorityId
        /// </summary>
        /// <param name="authorityId"></param>
        /// <returns></returns>
        public AuthorityDTO GetAuthorityById(int authorityId)
        {
            return proxy.ServiceClient.GetAuthorityById(authorityId);
        }

        /// <summary>
        /// Get All Authority Level
        /// </summary>
        /// <returns></returns>
        public List<AuthorityLevelDTO> GetAllAuthorityLevel()
        {
            return proxy.ServiceClient.GetAllAuthorityLevel();
        }

        /// <summary>
        /// Get All Authority
        /// </summary>
        /// <returns></returns>
        public List<AuthorityDTO> GetAllAuthority()
        {
            return proxy.ServiceClient.GetAllAuthority();
        }

        /// <summary>
        /// Get Search Authority
        /// </summary>
        /// <param name="authorityName"></param>
        /// <param name="levelName"></param>
        /// <returns></returns>
        public List<AuthorityDTO> SearchAuthority(string authorityName, int levelId)
        {
            return proxy.ServiceClient.SearchAuthority(authorityName, levelId);
        }
    }
}
